import java.util.ArrayList;
import java.util.List;
import java.util.Random;

    public class cxc2 {

        public static void main(String[] args) {
            List<String> equations = generateEquations(50);  // 这里可以调整生成的算式数量，此处示例为20个
            printEquations(equations);
        }

        // 生成指定数量的算式
        public static List<String> generateEquations(int numEquations) {
            List<String> equations = new ArrayList<>();
            Random random = new Random();
            for (int i = 0; i < numEquations; i++) {
                boolean isAddition = random.nextBoolean();
                if (isAddition) {
                    equations.add(generateAddition());
                } else {
                    equations.add(generateSubtraction());
                }
            }
            return equations;
        }

        // 生成加法算式，保证和不超过100
        public static String generateAddition() {
            Random random = new Random();
            int num1 = random.nextInt(101) + 100;  // 生成100到200之间的数
            int num2 = random.nextInt(201) - 100;  // 生成 -100到100之间的数
            int sum = num1 + num2;
            while (sum > 100) {
                num2 = random.nextInt(201) - 100;
                sum = num1 + num2;
            }
            return num1 + " + " + num2 + " = " + sum;
        }

        // 生成减法算式，保证差不小于0
        public static String generateSubtraction() {
            Random random = new Random();
            int num1 = random.nextInt(101) + 100;  // 生成100到200之间的数
            int num2 = random.nextInt(101);  // 生成0到100之间的数
            int diff = num1 - num2;
            return num1 + " - " + num2 + " = " + diff;
        }

        // 格式化输出算式列表
        public static void printEquations(List<String> equations) {
            int equationsPerLine = 4;  // 可以根据需要调整每行显示的算式数量
            for (int i = 0; i < equations.size(); i++) {
                System.out.print(equations.get(i));
                if ((i + 1) % equationsPerLine == 0) {
                    System.out.println();
                } else {
                    System.out.print("\t");

                }
            }
        }
    }
